package com.mars.ticket.config;

import java.util.Scanner;

/**
 * @author wq
 * @version 1.0
 * @date 2021/03/18 16:08
 */
public class test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入圆的大小:");
        String r = sc.nextLine();
        System.out.println("java Shapes circle " + r);
        circle(Integer.parseInt(r));

    }

    public static void circle(int r) {
        for (int y = 0; y <= 2 * r; y += 2) {
            int x = (int) Math.round(r - Math.sqrt(2 * r * y - y * y));
            int len = 2 * (r - x);
            // 圆左的空白
            for (int i = 0; i <= x; i++) {
                System.out.print(" ");
            }
            // 左半圆
            System.out.print("XXX");
            // 中间空白
            for (int j = 0; j <= len; j++) {
                System.out.print(' ');
            }
            // 右半圆
            System.out.println("XXX");
        }
    }
}
